#pragma pack(1)
#pragma once

#define RXBIT_PACKAGE_HEADER_VALUE 0x5A5A5A5A
#define RXBIT_PACKAGE_TAILER_VALUE 0xA5A5A5A5
#define RXBIT_DATATYPE_TARGET 0x0065
#define RXBIT_DATATYPE_STATISTIC 0x0080

// Msg65类型数据体
typedef struct
{
    uint16_t id;
    uint8_t lane;
    uint8_t type; // 目标类型：0-点目标；1-小型车；2-中型车；3-大型车；4-摩托车；5-自行车；6-宽大目标；7-行人。0xFF表示未知。
    uint8_t length;
    uint8_t width;
    uint8_t height;
    int16_t rcs;
    int16_t distY; // 纵向距离
    int16_t distX; // 横向距离
    int16_t speedY;
    int16_t speedX;
    int16_t speed; // 目标运动速度
    int16_t accY;        // 纵向加速度
    int16_t accX;       // 横向加速度
    int16_t acc;  // 目标运动加速度
    uint16_t heading;       // 偏航
    int32_t longitude;      // 经度
    int32_t latitude;       // 纬度
    int16_t altitude;       // 海拔高度
    uint8_t dynCharac;      // 目标动态特征 0-运动；1-静止；2-来向；3-静止候选；4-未知；5-横穿静止；6-横穿运动；7-运动后停止
    uint8_t cReserverd1;
    uint8_t cReserverd2[2];
    uint8_t nObjIdHigh;
    int16_t nDistYHigh;
    int16_t nDistXHigh;
    uint8_t cReserverd3[2];
} RxbitRadarMsg65Item;

// Msg65类型数据头
typedef struct
{
    uint16_t objNumber; //
    uint8_t laneNumber;
    int32_t longitude; //
    int32_t latitude;  //
    int16_t altitude;
    uint16_t northAngle;
    uint8_t frameNum[3];
    uint16_t deflectionAngle;
    uint16_t nIpIndex; // 雷达IP标识 IP后两段
    uint8_t cReserverd[4];
    RxbitRadarMsg65Item lists[];
} RxbitRadarMsg65;

/// <summary>
/// 包头
/// </summary>
typedef struct
{
    uint32_t head;
    uint16_t dataLen;
    uint8_t version;
    uint16_t dataType;
    char deviceId[20];
    uint8_t cYear;
    uint8_t cMon;
    uint8_t cDay;
    uint8_t cHour;
    uint8_t cMin;
    uint8_t cSec;
    uint16_t cMilliSec;

    // RxbitRadarMsgHead msgHead;

    /*uint32_t crc;
    uint32_t tail = 0xA5A5A5A5;*/
} RxbitRadarPackageHead;

enum MsgType
{
    MSG65 = 0x0065,
    MSG80 = 0x0080,
    MSG81 = 0x0081,
    MSG82 = 0x0082,
    MSG83 = 0x0083,
    MSG84 = 0x0084
};

// 目标类型：0-点目标；1-小型车；2-中型车；3-大型车；4-摩托车；5-自行车；6-宽大目标；7-行人。0xFF表示未知。
enum MsgBusType
{
    MsgPoint = 0,
    MsgCar,
    MsgBus,
    MsgTruck,
    MsgMotor,
    MsgBike,
    MsgLargeTarget,
    MsgPerson,
    MsgUnknown = 0xff
};

#pragma pack()